package com.lson.bus;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.bus.event.RemoteApplicationEvent;
import org.springframework.context.ApplicationContext;
@Slf4j
public class RemoteApplicationEventPublisher {
    public static void publishEvent(RemoteApplicationEvent event) {
        ApplicationContext context = ApplicationContextHolder.getApplicationContext();
        if(null != context) {
            context.publishEvent(event);
            log.info("已发布事件:{}", event);
        }else{
            log.warn("无法获取到当前Spring上下文信息，不能够发布事件");
        }
    }
}
